home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 016a / gofer221.zip / MATCH < prev    next >
Text File  |  1991-11-20  |  853b  |  28 lines

  1.  
  2. match []       ys       = null ys
  3. match ('*':ps) xs       = or (map (match ps) (tails xs))
  4. match (p:ps)   []       = False
  5. match (p:ps)   (c:cs)
  6.             | p==c      = match ps cs
  7.             | otherwise = False
  8.  
  9. -- Some combinatorial problems:
  10.  
  11. tails []         = [[]]
  12. tails xs'@(x:xs) = xs' : tails xs
  13.  
  14. inits []         = [[]]
  15. inits (x:xs)     = [] : map (x:) (inits xs)
  16.  
  17. perms []         = [[]]
  18. perms (x:xs)     = concat (map (inter x) (perms xs))
  19.                    where inter x []         = [[x]]
  20.                          inter x ys'@(y:ys) = (x:ys') : map (y:) (inter x ys)
  21.  
  22. subs []          = [[]]
  23. subs (x:xs)      = subs xs ++ map (x:) (subs xs)
  24.  
  25. segs             = concat . map tails' . reverse . inits
  26.                    where tails' []         = []
  27.                          tails' xs'@(_:xs) = xs' : tails' xs
  28.